using KenEgozi.Com.Domain.Aggregates.Post;
using KenEgozi.Com.Domain.Interfaces.Factories;
using KenEgozi.Com.Domain.Interfaces.Services;

namespace KenEgozi.Com.Domain.Factories
{
	public class PostFactory : IPostFactory
	{
		private readonly IUrlFriendlyStringTransformService urlFriendlyStringTransformService;
		public PostFactory(IUrlFriendlyStringTransformService urlFriendlyStringTransformService)
		{
			this.urlFriendlyStringTransformService = urlFriendlyStringTransformService;
		}

		public Post Create(string title, string content)
		{
			Post post = new Post();
			post.Content = content;
			post.Title = title;
			post.Permalink = string.Format("{0:yyyy/MM/dd}/{1}.aspx",
				post.Lifecycle.CreationDate,
				urlFriendlyStringTransformService.Execute(title));
			return post;
		}
	}
}